<template>

</template>
<script>
import {isIos} from '@/until/QFH5.js'
export default {
    name: 'clickPop',
    props: {
        voice: {
            type: String,
            default:''
        },
        
    },
    data(){
        return {
            audio:null
        }
    },
    mouted() {

    },
    methods: {
        playVoice() {
            if(isIos()){
                this.playVoiceIos()
                return
            }
            if(this.audio==null){
                let voice =  this.voice!=''?  this.voice : require('../../static/redpkg/click.mp3')
                this.audio = new Audio(voice)
                this.audio.play()
            }else{
                this.audio.currentTime = 0
                this.audio.play()
            }
            
        },
        playVoiceIos() {
            let voice =  this.voice!=''?  this.voice : require('../../static/redpkg/click.mp3')
			let audio2 = new Audio(voice)
			audio2.play()
            let endEvent = function(){
				 // 清除音频源
				audio2.src = '';
				// 移除事件监听器
				audio2.removeEventListener('ended',endEvent);
				// 释放对音频对象的引用
				audio2 = null;
			}
			audio2.addEventListener('ended',endEvent)
        }
    }
}
</script>
<style lang="scss" scoped>
</style>